package com.xulinhao.sportplay.controller;/**
 * @author xulinhao
 * @create 2021-07-13 10:36
 */

import com.alibaba.fastjson.JSON;
import com.xulinhao.sportplay.dao.MenuDao;
import com.xulinhao.sportplay.pojo.MainMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @Author xlh
 * @packagename: com.xulinhao.sportplay.controller
 * @classname: MenuController
 * @Description:
 * @Date 2021/7/13
 */
@RestController
public class MenuController {
    @Autowired
    MenuDao menuDao;

    @RequestMapping("/menus")
    public String getAllMenus(){
        System.out.println("访问成功");
        HashMap<String, Object> data = new HashMap<>();
        List<MainMenu> menus = menuDao.getMenus();
        if (menus != null) {
            data.put("menus", menus);
            data.put("flag", 200);
        }else {
            data.put("flag", 404);
        }
        String s = JSON.toJSONString(data);
        return s;
    }
}
